{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}<title>课程机构列表 - frost在线网</title>{% endblock %}
{% block custom_bread %}
<section>
    <div class="wp">
        <ul class="crumbs">
            <li><a href="{% url 'index' %}">首页</a>></li>
            <li>课程机构</li>
        </ul>
    </div>
</section>
{% endblock %}

{% block main_content %}
<section>
    <div class="wp butler_list_box list">
        <div class='left'>
            <div class="listoptions">
                <ul>
                    <li>
                        <h2>机构类别</h2>
                        <div class="cont">
                            <a href="?city={{ city_id }}{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}"><span class="{% ifequal category '' %}active2{% endifequal %}">全部</span></a>

                            <a href="?category=train&city={{ city_id }}{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}">
                                <span class="{% ifequal category 'train' %}active2{% endifequal %}">培训机构</span>
                            </a>

                            <a href="?category=colleges&city={{ city_id }}{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}">
                                <span class="{% ifequal category 'colleges' %}active2{% endifequal %}">高校</span>
                            </a>

                            <a href="?category=personal&city={{ city_id }}{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}">
                                <span class="{% ifequal category 'personal' %}active2{% endifequal %}">个人</span>
                            </a>

                        </div>
                    </li>
                    <li>
                        <h2>所在地区</h2>
                        <!--<div class="more">更多</div>-->
                        <div class="cont">
                            <a href="?category={{ category }}{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}"><span class="{% ifequal city_id '' %}active2{% endifequal %}">全部</span></a>
                            {% for city in city_list %}
                            <a href="?category={{ category }}&city={{ city.id }}{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}">
                                <span class="{% ifequal city.id|stringformat:'i' city_id %}active2{% endifequal %}">{{ city.name }}</span>
                            </a>
                            {% endfor %}
                        </div>
                    </li>
                </ul>
            </div>
            <div class="all">共<span class="key">{{ org_nums }}</span>家</div>
            <div class="butler_list company list">
                <div class="layout">
                    <div class="head">
                        <ul class="tab_header">
                            <li class="{% ifequal sort '' %}active{% endifequal %}">
                                <a href="?category={{ category }}&city={{ city_id }}{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}">全部</a>
                            </li>
                            <li class="{% ifequal sort 'students' %}active{% endifequal %}">
                                <a href="?category={{ category }}&city={{ city_id }}&sort=students{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}">学习人数 &#8595;</a>
                            </li>
                            <li class="{% ifequal sort 'courses' %}active{% endifequal %}">
                                <a href="?category={{ category }}&city={{ city_id }}&sort=courses{% ifequal search_keywords '' %}{% else %}&keywords={{search_keywords}}{% endifequal%}">课程数 &#8595;</a>
                            </li>
                        </ul>
                    </div>
                    {% for org in org_list.object_list %}
                    <dl class="des difdes">
                        <dt>
                            <a href="{% url 'organization:org_home' org.id %}">
                                <img width="200" height="120" class="scrollLoading"
                                     data-url="{{ MEDIA_URL }}{{ org.image }}"/>
                            </a>
                        </dt>
                        <dd>
                            <div class="clearfix">
                                <a href="{% url 'organization:org_home' org.id %}">
                                    <h1>{{ org.name }}</h1>
                                </a>
                            </div>
                            <ul class="cont">
                                <li class="first"><p class="pic9">课程数：<span>{{ org.course_set.count }}</span></p>
                                    <p class="c7">学习人数：<span>{{ org.students }}</span></p></li>
                                <li class="c8" style="padding-left:18px;">{{ org.address }}</li>
                                <li class="pic10" style="padding-left:18px;">经典课程：
                                    {% for course in org.course_set.get_queryset|slice:':4' %}
                                    <a href="{% url 'courses:course_detail' course.id %}">{{ course.name }}</a>
                                    {% endfor %}
                                </li>
                            </ul>
                        </dd>
                    </dl>
                    {% endfor %}
                </div>
                <!-- {{ org_list.number }} -->
                <div class="pageturn">
                    <ul class="pagelist">
                        {% if org_list.has_previous %}
                        <li class="long"><a href="?{{ org_list.previous_page_number.querystring }}">上一页</a></li>
                        {% endif %}
                        {% for page in org_list.pages %}
                            {% if page %}
                                {% ifequal page org_list.number %}
                                <li class="active"><a href="?{{ page.querystring }}">{{ page }}</a></li>
                                {% else %}
                                <li><a href="?{{ page.querystring }}">{{ page }}</a></li>
                                {% endifequal %}
                            {% else %}
                            <li class="none">...</li>
                            {% endif %}
                        {% endfor %}
                        {% if org_list.has_next %}
                        <li class="long"><a href="?{{ org_list.next_page_number.querystring }}">下一页</a></li>
                        {% endif %}
                    </ul>
                </div>
            </div>
        </div>
        <div class="right companyright">
            <div class="head">我要学习</div>
            <form class="rightform" id="jsStayForm">
                {% csrf_token %}
                <div>
                    <img src="{% static 'images/rightform1.png' %}"/>
                    <input type="text" name="name" id="companyName" placeholder="名字" maxlength="25"/>
                </div>
                <div>
                    <img src="{% static 'images/rightform2.png' %}"/>
                    <input type="text" name="mobile" id="companyMobile" placeholder="联系电话"/>
                </div>
                <div>
                    <img src="{% static 'images/rightform3.png' %}"/>
                    <input type="text" name="course_name" id="companyAddress" placeholder="课程名" maxlength="50"/>
                </div>
                <p class="error company-tips" id="jsCompanyTips"></p>
                <input class="btn" type="text" id="jsStayBtn" value="立即咨询 >"/>
            </form>
        </div>

        <div class="right companyrank layout">
            <div class="head">授课机构排名</div>

            {% for hot_org in hot_org_list %}
            <dl class="des">
                <dt class="num fl">{{ forloop.counter }}</dt>
                <dd>
                    <a href="{% url 'organization:org_home' hot_org.id %}"><h1>{{ hot_org.name }}</h1></a>
                    <p>{{ hot_org.city }}</p>
                </dd>
            </dl>
            {% endfor %}


        </div>
    </div>
</section>
{% endblock %}
{% block custom_js %}
<script>
    $(function(){
        $('#jsStayBtn').on('click', function(){
            $.ajax({
                cache: false,
                type: "POST",
                url:"{% url 'organization:add_ask' %}",
                data:$('#jsStayForm').serialize(),
                async: true,
                success: function(data) {
                    if(data.status == 'success'){
                        $('#jsStayForm')[0].reset();
                        alert("提交成功")
                    }else if(data.status == 'fail'){
                        $('#jsCompanyTips').html(data.msg)
                    }
                },
            });
        });
    })
</script>
{% endblock %}
</body>
</html>
